﻿package  {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.utils.getDefinitionByName;
	
	public class WIcon extends MovieClip {
		
		public var current:int = 0; //0-hidden; 1-icon
		public var icons:Array;
		
		
		public function WIcon(index:int = 0){
			super();
			// constructor code
			this.current = index;
			this.icons = new Array(null);
			var ClassRef:Class;
			var i:int;
			for(i=0; i<Logic.wheelIcons.length; i++)
			{
				ClassRef = Helper.getClass(Logic.wheelIcons[i]);
				if(ClassRef)
				{
					this.icons.push(new ClassRef());
					this.icons[i+1].name = 'ic_'+(i+1);
					this.icons[i+1].visible = ((i+1)==this.current) ? true : false;
					this.addChild(this.icons[i+1]);
				} else {
					this.icons.push(null);
				}
			}
		}
		
		public function showIcon(index:int)
		{
			if(this.icons[current])
			{
				this.icons[current].visible = false;
			}
			if(this.icons[index])
			{
				this.icons[index].visible = true;
			}
			this.current = index;
		}
	}
	
}
